<?php

namespace app\agent\controller;

use app\agent\model\BalanceChangeApply as BalanceChangeApplyModel;
use app\agent\validate\BalanceChangeApply as BalanceChangeApplyValidate;

/**
 * 加款申请
 */
class BalanceChangeApply extends Controller
{
    /**
     * 列表.
     */
    public function list()
    {
        $model = new BalanceChangeApplyModel();
        $data = input('post.');
        $data['agent'] = $this->agent;

        return $model->getList($data);
    }

    /**
     * 加款申请
     */
    public function create()
    {
        $data = input('post.');
        $validate = new BalanceChangeApplyValidate();
        if (!$validate->scene('create')->check($data)) {
            return fail($validate->getError());
        }

        $model = new BalanceChangeApplyModel();
        $data['agent'] = $this->agent;

        return $model->create($data);
    }

    /**
     * 撤销申请
     */
    public function cancel()
    {
        $data = input('post.');
        $validate = new BalanceChangeApplyValidate();
        if (!$validate->scene('cancel')->check($data)) {
            return fail($validate->getError());
        }

        $model = new BalanceChangeApplyModel();
        $data['agent'] = $this->agent;

        return $model->cancel($data);
    }
}
